import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

import Home from "@/pages/Home";
import About from "@/pages/About";
import News from "@/pages/Home/News";
import Message from "@/pages/Home/Message";
import Detail from "@/pages/Home/Message/Detail";
export default new VueRouter({
  mode: "history",
  routes: [
    {
      path: "/home",
      component: Home,
      children: [
        {
          name: "xinwen",
          path: "news",
          component: News,
        },
        {
          name: "xiaoxi",
          path: "message",
          component: Message,
          children: [
            {
              name: "xiang",
              path: "detail",
              component: Detail,
              // props的第一种写法,对象写法,把对象中的一组一组的key-value传给Detail
              // props: { a: "哈哈" },
              // props的第二种写法,布尔值写法, 把收到的params参数,传给Detail
              // props: true
              // 第三种写法  函数写法
              props(route){
                return route.query
              }
            },
          ],
        },
        {
          path: "",
          component: News,
        },
      ],
    },
    {
      name: "guanyu",
      path: "/about",
      component: About,
    },
    {
      path: "/",
      component: About,
    },
  ],
});
